#region License

// Copyright (c) 2013, ClearCanvas Inc.
// All rights reserved.
// http://www.clearcanvas.ca
//
// This file is part of the ClearCanvas RIS/PACS open source project.
//
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// the ClearCanvas RIS/PACS open source project.  If not, see
// <http://www.gnu.org/licenses/>.

#endregion

// This file is auto-generated by the ClearCanvas.Model.SqlServer.CodeGenerator project.

namespace ClearCanvas.ImageServer.Model
{
    using System;
    using System.Xml;
    using ClearCanvas.Enterprise.Core;
    using ClearCanvas.ImageServer.Enterprise;
    using ClearCanvas.ImageServer.Enterprise.Command;
    using ClearCanvas.ImageServer.Model.EntityBrokers;

    [Serializable]
    public partial class Filesystem: ServerEntity
    {
        #region Constructors
        public Filesystem():base("Filesystem")
        {}
        public Filesystem(
             String _filesystemPath_
            ,Boolean _enabled_
            ,Boolean _readOnly_
            ,Boolean _writeOnly_
            ,FilesystemTierEnum _filesystemTierEnum_
            ,Decimal _lowWatermark_
            ,Decimal _highWatermark_
            ,String _description_
            ):base("Filesystem")
        {
            FilesystemPath = _filesystemPath_;
            Enabled = _enabled_;
            ReadOnly = _readOnly_;
            WriteOnly = _writeOnly_;
            FilesystemTierEnum = _filesystemTierEnum_;
            LowWatermark = _lowWatermark_;
            HighWatermark = _highWatermark_;
            Description = _description_;
        }
        #endregion

        #region Public Properties
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="FilesystemPath")]
        public String FilesystemPath
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="Enabled")]
        public Boolean Enabled
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="ReadOnly")]
        public Boolean ReadOnly
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="WriteOnly")]
        public Boolean WriteOnly
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="FilesystemTierEnum")]
        public FilesystemTierEnum FilesystemTierEnum
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="LowWatermark")]
        public Decimal LowWatermark
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="HighWatermark")]
        public Decimal HighWatermark
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="Filesystem", ColumnName="Description")]
        public String Description
        { get; set; }
        #endregion

        #region Static Methods
        static public Filesystem Load(ServerEntityKey key)
        {
            using (var context = new ServerExecutionContext())
            {
                return Load(context.ReadContext, key);
            }
        }
        static public Filesystem Load(IPersistenceContext read, ServerEntityKey key)
        {
            var broker = read.GetBroker<IFilesystemEntityBroker>();
            Filesystem theObject = broker.Load(key);
            return theObject;
        }
        static public Filesystem Insert(Filesystem entity)
        {
            using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                Filesystem newEntity = Insert(update, entity);
                update.Commit();
                return newEntity;
            }
        }
        static public Filesystem Insert(IUpdateContext update, Filesystem entity)
        {
            var broker = update.GetBroker<IFilesystemEntityBroker>();
            var updateColumns = new FilesystemUpdateColumns();
            updateColumns.FilesystemPath = entity.FilesystemPath;
            updateColumns.Enabled = entity.Enabled;
            updateColumns.ReadOnly = entity.ReadOnly;
            updateColumns.WriteOnly = entity.WriteOnly;
            updateColumns.FilesystemTierEnum = entity.FilesystemTierEnum;
            updateColumns.LowWatermark = entity.LowWatermark;
            updateColumns.HighWatermark = entity.HighWatermark;
            updateColumns.Description = entity.Description;
            Filesystem newEntity = broker.Insert(updateColumns);
            return newEntity;
        }
        #endregion
    }
}
